package com.tuozixuan.camel.delay;

import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;

@Component
public class DelayDemoRoute extends RouteBuilder {

	@Override
	public void configure() {
	    
	    // 延迟3000毫秒
	    //from("timer:firedOnceTimer?repeatCount=1").delay(3000).setBody().constant("delay 3000ms").to("log:DelayDemoLog");
	    
	    // 随机延迟3000-10000毫秒
	    //from("timer:firedOnceTimer?repeatCount=1").delay(simple("${random(3000,10000)}")).setBody().constant("delay 3000ms").to("log:DelayDemoLog");
	    
	    // 异步延迟3000毫秒
	    //from("timer:firedOnceTimer?repeatCount=1").delay(3000).asyncDelayed().setBody().constant("delay 3000ms").to("log:DelayDemoLog");
	    
	    // 使用Bean方法计算延迟时间
	    //from("timer:firedOnceTimer?repeatCount=1").delay().method("delayBean", "computeDelay").asyncDelayed().setBody().constant("delay 3000ms").to("log:DelayDemoLog");
	    
	}

}
